package it.koutifaris.travianmap.info;

import static it.koutifaris.testforclassutils.IsTestForAssert.assertIsTestFor;
import it.koutifaris.travianmap.model.Tribe;
import junit.framework.Assert;
import android.test.AndroidTestCase;

public class TroopFileParserTest extends AndroidTestCase {

	private TroopFileParser parser;

	@Override
	protected void setUp() throws Exception {
		parser = new TroopFileParser();
	}

	public void testPkgAndName() {
		assertIsTestFor(TroopFileParser.class);
	}

	public void testParseLine() {
		String entry = "Phalanx				15	40	50	1	7	INFANTRY	GAUL";

		Troop troop = parser.parseLine(entry);

		Assert.assertEquals("Phalanx", troop.name());
		Assert.assertEquals(15, troop.offence());
		Assert.assertEquals(40, troop.infantryDefence());
		Assert.assertEquals(50, troop.cavalryDefence());
		Assert.assertEquals(7, troop.speed());
		Assert.assertEquals(TroopType.INFANTRY, troop.type());
		Assert.assertEquals(Tribe.GAUL, troop.tribe());
	}

	public void testSkipComment() {
		String comment = "// This is a comment";

		boolean skip = parser.skipLine(comment);

		Assert.assertTrue(skip);
	}

	public void testSkipEmptyLine() {
		String emptyLine = "";

		boolean skip = parser.skipLine(emptyLine);

		Assert.assertTrue(skip);
	}

	public void testSkipEmptyLineWithWhithCharacters() {
		String emptyLine = " \t";

		boolean skip = parser.skipLine(emptyLine);

		Assert.assertTrue(skip);
	}

}
